package demo.thread;


public class SynDemo2 {
	public static void main(String[] args) {
		SynDemo2 demo = new SynDemo2();
		demo.start();
	}
	
	public void start(){
		final Worker output = new Worker();
		new Thread() {
			public void run() {
				output.output("zhangsan");
			};
		}.start();		
		new Thread() {
			public void run() {
				output.output("lisi");
			};
		}.start();
	}
	
	class Worker {
		public void output(String name) {
			for(int i = 0; i < name.length(); i++) {
				System.out.print(name.charAt(i));
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}
}
